package com.androidvizlab.bachelor.customcomponents.fragments;

import com.androidvizlab.bachelor.R;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

/**
 * Class used to create dialog using fragment
 * 
 * @author The Hive
 */
public class CustomDialogFragment extends DialogFragment{
		
	//Listener
	private DialogInterface.OnClickListener onClickListener = null;
	
	//Context
	private Context context = null;
	
	//Titles and content
	private String title = ""; //dialog title
	private String content = ""; // dialog content/message
	
	
	/**
	 * Creates a new instance of CustomDialogFragment
	 * @param title
	 * @return
	 */
	public static CustomDialogFragment newInstance(int title)
	{
		CustomDialogFragment dialogfragment = new CustomDialogFragment();
		
		Bundle arguments = new Bundle();
		arguments.putInt("title",title);
		
		dialogfragment.setArguments(arguments);
		
		return dialogfragment;
	}
	
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState)
	{
		AlertDialog d = new AlertDialog.Builder(context)
			.setIcon(R.drawable.ic_alert)
			.setTitle(title)
			.setMessage(content)
			.setPositiveButton(R.string.btn_text_ok,onClickListener)
			.create();
		
		return d;
	}
	
	//*** GETTERS AND SETTERS ***//
	
	public DialogInterface.OnClickListener getOnClickListener() {
		return onClickListener;
	}

	public void setOnClickListener(DialogInterface.OnClickListener onClickListener) {
		this.onClickListener = onClickListener;
	}

	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
}
